// user_pkg/pages/recharge/recharge.js
Page({
  data: {
    balance: 0,
    customMoney: null
  },
  onShow() {
    this.getBalance()
  },
  // 获取账户余额
  async getBalance() {
    const res = await wx.http.get('/user/assets')
    const balance = res.data.data.assets.balance
    this.setData({balance})
  },
  // 获取输入金额
  getCustomMoney(ev) {
    this.setData({customMoney: ev.detail.value})
  },
  // 充值
  async recharge() {
    const res = wx.http.post('/recharge/submit', {
      planId: 0,
      customMoney: this.data.customMoney
    })
    console.log(res)
  }
})